home *** CD-ROM | disk | FTP | other *** search
- TECHNICAL NOTES ON FDREAD v1.20cj
-
- Some of this will be old hat to the hackers out there, but I'm going to
- cover some background for the rest of you.
-
- Current versions (starting with 3.0, I think) of PC/MS-DOS use the infor-
- mation on the format of a diskette found in the boot sector. DOS can look
- here and learn about the number of cylinders, the number of heads, and the
- number of sectors per track. It also learns about the number of FATs (File
- Allocation Tables) and the size of the root directory.
-
- FDFORMAT allows you to modify all of these characteristics, and it writes a
- boot record on the floppy disk that reflects them.
-
- Most versions of DOS will use this information to control their file system
- on floppies. There may be some DOSs out there that don't: ancient ones, or
- poorly modified versions, or ineptly written clones. If you have such a
- DOS you can't use over-formatted disks.
-
- DISKCOPY and DISKCOMP pay no attention the the data on a disk, but they
- only know about the standard DOS formats and will not copy or compare
- diskettes with unusual numbers or sectors per track or unusual numbers of
- cylinders.
-
- If you decide to go for stranger formats, to back them up you must FDFORMAT
- another disk and use file copy functions to copy the files.
-
- But this is not DOS' problem; it's the problem of DISKCOPY and DISKCOMP.
-
- Even if you insist on using DISKCOPY or similar programs (PCSHELL's Disk
- Copy funtion, for instance) you can still get value from FDFORMAT. You
- can, for example, format a 360K diskette with 9 sectors per track and forty
- cylinders and two heads (the normal for a 360K disk) but with 176 entries
- in the root directory and 1 sector per allocation cluster (two is normal
- here). Such a diskette will have about 2K less space for data than a
- normal 360K diskette, but it a better format for a diskette on which you
- are storing lots of small files (letters, for example) since you will run
- out of root directory and diskette space at about the same time and there
- will be MUCH less space wasted in the partially used last cluster of each
- file.
-
- Most important: such a disk can be easily copied and compared with DISKCOPY
- and DISKCOMP. You won't need to use FDREAD, either.
-
- Most other programs with similar functions will not do well with over-
- formatted disks. Some will do the job correctly. COPYIIPC, for example
- will copy over-formatted "DD" disks, though it may have some problems going
- over 80 tracks (I haven't tried), and it may not handle high-density
- diskettes.
-
- You may have some other software that has problems, but as long as they use
- the DOS file system, you'll probably be all right.
-
- The REAL problems we have are with the BIOS.
-
- From the beginning the BIOSs have gotten their information about the
- parameters used to set up the Floppy Disk Controller from a Diskette
- Parameter Table whose address is stored in interrupt vector 1Eh (the four
- bytes beginning at location 0000:0078h). This table contains such things
- as the diskette seek step time, the size of the inter-sector gaps for
- formatting, and other things. But to us the important item is the number of
- sectors per track. The BIOS uses this value to determine the maximum sector
- number which it must give to the FDC (Floppy Disk Controller) as part of
- the command sequence for things like reading, writing and verifying. The
- FDC will stop transferring data from a track after it encounters a sector
- with this number. It is also used to tell the FDC how many sectors there
- are per track when it is formatting. If you have a diskette with 9 sectors
- per track, but you set the FDC to look for a maximum of 8, and you ask it
- to read 9 sectors, it will read the first 8 sectors, then return a sector
- not found error on the sector 9, even though sector 9 is out there.
-
- The original version of FDREAD intercepts the calls to the BIOS for disk
- services. If it sees a READ, WRITE or VERIFY command, it just plugs a
- sufficiently large value (25) into the Floppy Disk Parameter Table to
- ensure the reading of the track.
-
- Now let's see what happens when we try to run a typical "normal" format
- program. The format program sets the gap length and number of sectors per
- track into the Diskette Parameter Table, then calls the BIOS to format a track.
- So far so good. This is not a READ, WRITE or VERIFY command, so FDREAD
- leaves the Diskette Parameter Table alone. Now the format program issues a
- VERIFY to verify the formatted track. Oops-- FDREAD intercepts and changes
- the number of sectors in the Diskette Parameter Table to 25. The verify
- proceeds and is good. Now the formatter issues a command to format the
- next track. But the BIOS thinks it now has 25 sectors to write and
- overwrites the front part of the track with other stuff. Now the track
- won't verify, since the first sector, having been overwritten, cannot be
- found.
-
- Sigh.
-
- So I have modified FDREAD so that instead of plugging 25 into the number-
- of-sectors slot in the Diskette Parameter Table it checks the caller's
- parameters. It adds the starting sector number (from the CL register) to
- the number of sectors to read (from the AL register), then knocks off 1.
- This will give us the sector number of the highest sector the caller wants
- to read. If this exceeds the value in the Diskette Parameter Table, FDREAD
- replaces it. Otherwise it leaves it alone. Yes, the procedure is a bit
- more complicated, but it gets along better with more software and more
- BIOSs.
-
- There will, of course, be BIOSs that don't use the Diskette Parameter Table
- and you won't be able to use over-formatted disks on machines so equipped.
- (Version 9.09 of the BIOS on the Jameco JE1049 FDC for the XT has this
- problem while version 7.10 [marked internally as 10.25, the version from
- early 1989], works fine.) IBM ATs (real ones) work properly and several AT
- clones I have tried (including a Jameco model with an AMI BIOS) work just
- as slick as anything, but there are exceptions, so check carefully. And if
- it doesn't work----
-
- Well, hey! You can always get your money back, right?
-
- Of course there will be the occasional piece of software that can't live
- with our modified FDREAD. For those programs I have added the OFF and ON
- feature. For those of you who are writing software for which you MUST have
- FDREAD's functions OFF, you can even make a call (thru interrupt 13h) to
- turn FDREAD on and off. Check the listing of the modified FDREAD for
- instructions and examples.
-
- There is some additional code in FDREAD which can be activated by assem-
- bling it with the symbol MODE defined as 2, but this will only work on AT
- systems, and is for dealing with quad density 720K 5-1/4" floppies. The
- assembled and lunk (sink/sunk, drink/drunk, and all that) version in this
- package was assembled with MODE not defined so the extra code is NOT incor-
- porated.
-
-
- June, 1990 -- Crazy Jack
-